home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / cug191 / soundint.ase < prev    next >
Text File  |  1986-05-25  |  7KB  |  187 lines

  1. ;
  2. ;    SOUNDINT.ASM            (Eco-C88 version)              25 Feb 86
  3. ;
  4. ;   /* ------------------------------------------------------------ */
  5. ;   /*      This is a portion of the SOUND EFFECTS LIBRARY.         */
  6. ;   /*                                                              */
  7. ;   /*      Copyright (C) 1986 by Paul Canniff.                     */
  8. ;   /*      All rights reserved.                                    */
  9. ;   /*                                                              */
  10. ;   /*      This library has been placed into the public domain     */
  11. ;   /*      by the author.  Use is granted for non-commercial       */
  12. ;   /*      pusposes, or as an IMBEDDED PORTION of a commercial     */
  13. ;   /*      product.                                                */
  14. ;   /*                                                              */
  15. ;   /*      Paul Canniff                                            */
  16. ;   /*      PO Box 1056                                             */
  17. ;   /*      Marlton, NJ 08053                                       */
  18. ;   /*                                                              */
  19. ;   /*      CompuServe ID: 73047,3715                               */
  20. ;   /*                                                              */
  21. ;   /* ------------------------------------------------------------ */
  22. ;
  23. ; -------------------------------------------------------------------------
  24. ;    Define IBM PC ports used to control speakers
  25. ;
  26. KBCTL      EQU     61H        ;Keyboard control port (controls speaker too)
  27. SPKTMR     EQU     42H        ;8253 Timer address
  28. SPKCTL     EQU     43H        ;8253 Timer address
  29. ;
  30. ; -------------------------------------------------------------------------
  31. ;    Set up macros for segment values, etc.
  32. ;
  33.     INCLUDE PRO.H            ;Eco-C88 header file
  34. ;
  35. LPROG   EQU     0                       ;No Long code in Ecosoft C88
  36. ;
  37.     IF    LPROG
  38. ARGS    EQU    6                       ;Bytes on stack before args 
  39.     ELSE
  40. ARGS    EQU    4                       ;Bytes on stack before args
  41.     ENDIF
  42. ;
  43. ; -------------------------------------------------------------------------
  44. ;
  45.         IF      LPROG
  46.     EXTRN    _sound_out:FAR          
  47.     EXTRN    _sound_done:FAR
  48.         ENDIF
  49. ;
  50. $b$prog    segment    word public 'code'
  51. ;
  52.         IF      (LPROG EQ 0)
  53.     EXTRN    _sound_out:NEAR          
  54.     EXTRN    _sound_done:NEAR
  55.         ENDIF
  56. ;
  57.     PUBLIC    _snd_irh
  58.     PUBLIC    _snd_giv
  59.     PUBLIC    _snd_siv
  60.     PUBLIC    _snd_brk
  61. ;
  62. ;
  63. ;
  64. _snd_irh PROC   FAR
  65.     STI                             ; Enable interrupts
  66.     PUSH    DS                      ;\
  67.     PUSH    ES                      ; \
  68.     PUSH    SI                      ;  \
  69.     PUSH    DI                      ;   \
  70.     PUSH    BP                      ; Save all registers
  71.     PUSH    AX                      ;   /
  72.     PUSH    BX                      ;  /
  73.     PUSH    CX                      ; /
  74.     PUSH    DX                      ;/
  75.     MOV    AX,SEG DGROUP           ;\
  76.     MOV    ES,AX                   ; Load expected segment values
  77.     MOV    DS,AX                   ;/
  78.     CALL    _sound_out              ; Call the real code
  79.     POP    DX                      ;\
  80.     POP    CX                      ; \
  81.     POP    BX                      ;  \
  82.     POP    AX                      ;   \
  83.     POP    BP                      ; Restore all registers
  84.     POP    DI                      ;   /
  85.     POP    SI                      ;  /
  86.     POP    ES                      ; /
  87.     POP    DS                      ;/
  88.         INT     61H                     ; Call previous INT vector
  89.     IRET                            ; Return
  90. _snd_irh ENDP
  91. ;
  92. ;
  93.     IF    LPROG
  94. _snd_giv PROC   FAR
  95.     ELSE
  96. _snd_giv PROC   NEAR
  97.     ENDIF
  98.     PUSH    BP                      ;Save frame pointer
  99.     MOV    BP,SP                   ;Make new frame pointer
  100.     PUSH    ES                      ;Preserve ES, just in case
  101.     XOR    AX,AX                   ;Zero ES register so it will
  102.     MOV    ES,AX                   ;   point to low memory
  103.     MOV    BX,[BP+ARGS]            ;Make BX into proper offset,
  104.     SHL    BX,1                    ;   which is the vector number
  105.     SHL    BX,1                    ;   times 4 (2 shifts)
  106.     PUSHF                           ;Save INT flag
  107.     CLI                             ;Disable interrupts
  108.     MOV    AX,ES:[BX]              ;Get the low ...
  109.         MOV     BX,ES:[BX+2]            ; ... and high words of vector
  110.     POPF                            ;Restore INT flag
  111.     POP    ES                      ;Preserve ES, just in case
  112.     POP    BP                      ;Restore caller's frame
  113.     RET
  114. _snd_giv ENDP
  115. ;
  116. ;
  117.     IF    LPROG
  118. _snd_siv PROC   FAR
  119.     ELSE
  120. _snd_siv PROC   NEAR
  121.     ENDIF
  122.     PUSH    BP                      ;Save frame pointer
  123.     MOV    BP,SP                   ;Make new frame pointer
  124.     PUSH    ES                      ;Preserve ES, just in case
  125.     XOR    AX,AX                   ;Zero ES register so it will
  126.     MOV    ES,AX                   ;   point to low memory
  127.     MOV    BX,[BP+ARGS]            ;Make BX into proper offset,
  128.     SHL    BX,1                    ;   which is the vector number
  129.     SHL    BX,1                    ;   times 4 (2 shifts)
  130.     PUSHF                           ;Save INT flag
  131.     CLI                             ;Disable interrupts
  132.     MOV    AX,[BP+ARGS+2]          ;Get low word of vector 
  133.     MOV    ES:[BX],AX              ;   and install it.
  134.     MOV    AX,[BP+ARGS+4]          ;Get high word of vector
  135.     MOV    ES:[BX+2],AX            ;   and install it.
  136.     POPF                            ;Restore INT flag
  137.     POP    ES                      ;Preserve ES, just in case
  138.     POP    BP                      ;Restore caller's frame
  139.     RET
  140. _snd_siv ENDP
  141. ;
  142. ;
  143. _snd_brk PROC   FAR
  144.     STI
  145.     PUSH    DS                      ;\
  146.     PUSH    ES                      ; \
  147.     PUSH    SI                      ;  \
  148.     PUSH    DI                      ;   \
  149.     PUSH    BP                      ; Save all registers
  150.     PUSH    AX                      ;   /
  151.     PUSH    BX                      ;  /
  152.     PUSH    CX                      ; /
  153.     PUSH    DX                      ;/
  154.     MOV    AX,SEG DGROUP           ;\
  155.     MOV    ES,AX                   ; Load expected segment values
  156.     MOV    DS,AX                   ;/
  157.     CALL    _sound_done              ; Tidy up loose ends
  158.         CLC                             ; Clear Carry (see above desc.)
  159.     INT     23H                     ; Call the real handler
  160.     POP    DX                      ;\
  161.     POP    CX                      ; \
  162.     POP    BX                      ;  \
  163.     POP    AX                      ;   \
  164.     POP    BP                      ; Restore all registers
  165.     POP    DI                      ;   /
  166.     POP    SI                      ;  /
  167.     POP    ES                      ; /
  168.     POP    DS                      ;/
  169.         JC      abort                   ; Abort if handler set carry flag
  170. ;
  171. cont:   IRET                            ; Continue, use IRET
  172. ;
  173. abort:  POPF                            ; Get flags off stack
  174.         STC                             ; Pass "abort" message back to DOS
  175.         RET                             ; Long return to DOS
  176. _snd_brk ENDP
  177. ;
  178. ;
  179. $b$prog    ends
  180.     END
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.